package sjtu.rfid.rri.services.io;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * This interface defines a generic Connection API for different connection
 * methods. The actual connection can be socket,comm,bluetooth, etc.
 * 
 * @author jinghao
 * 
 */
public interface Connection {

	/**
	 * open an inputstream from this connection. you can use this inputstream to
	 * get data from connection
	 * 
	 * @return an inputstream
	 * @throws IOException
	 */
	public InputStream openInputStream() throws IOException;

	/**
	 * open an outputstream from this connection. you can use this outputstream
	 * to send data from connection
	 * 
	 * @return
	 * @throws IOException
	 */
	public OutputStream openOutputStream() throws IOException;

	/**
	 * close the connection,the actual close implmentation and logic is related
	 * to actual implementation. normally, make sure you have closed any
	 * outputstream or inputstream.
	 * 
	 * @throws IOException
	 */
	public void close() throws IOException;

}
